Developer Documentation
PATHJava Developer Documentation > Mac OS Runtime for Java > JManager > Programming With JManager


Applet Control Functions

With the following functions you can find an applet through an HTML page, instantiate it within an AWT context, and set or receive information associated with it.


JMNewAppletLocatorFromInfo

Locates an applet synchronously using information in the applet locator information block structure.

OSStatus JMNewAppletLocatorFromInfo (
                     JMAppletLocatorRef* locatorRef,
                     JMSessionRef session,
                     const JMLocatorInfoBlock* info,
                     JMClientData data);
locatorRef
A pointer to the locator. On return, this parameter is the new applet locator.
session
The session in which you want to instantiate the applet.
info
A pointer to an applet locator information block structure. For more information, see The Applet Locator Information Block.
data
Optional client-specific data.
function result
A result code; see JManager Result Codes.

SEE ALSO

Finding Applets.

The JMNewAppletLocator function.

The JMDisposeAppletLocator function.


JMNewAppletLocator

Locates an applet asynchronously by fetching an HTML document from a specified URL.

OSStatus JMNewAppletLocator (
                     JMAppletLocatorRef* locatorRef,
                     JMSessionRef session,
                     const JMAppletLocatorCallbacks* callbacks,
                     const JMTextRef url,
                     const JMTextRef htmlText,
                     JMClientData data);
locatorRef
A pointer to the locator. On return, this parameter is the new applet locator.
session
The session in which you want to instantiate the applet.
callbacks
A pointer to an applet locator callbacks structure. For more information, see Applet Locator Callback Structure.
url
A text object containing the text of the URL.
htmlText
Optional text (stored as a text object) containing one or more applet tags.
data
Optional client-specific data.
function result
A result code; see JManager Result Codes.

DISCUSSION

If you have already retrieved the HTML document, you can pass it to JMNewAppletLocator in the htmlText argument. Otherwise, JMNewAppletLocator starts a separate thread to retrieve the document. The client application must call JIdle to allow the new thread time to retrieve the document. The callback that executes upon fetching the HTML document can occur either while this function is executing or some time after it has returned.

SEE ALSO

Finding Applets.

The JMNewAppletLocatorFromInfo function.

The JMDisposeAppletLocator function.


JMDisposeAppletLocator

Removes an applet locator.

OSStatus JMDisposeAppletLocator (JMAppletLocatorRef locatorRef);
locatorRef
The applet locator to remove.
function result
A result code; see JManager Result Codes.

DISCUSSION

Since the applet locator merely locates an applet, you can dispose of it after instantiating the applet. You can call JMDisposeAppletLocator while the thread created by JMNewAppletLocator function JMNewAppletLocator is still searching for the applet.

SEE ALSO

The JMNewAppletLocatorFromInfo function.


JMGetAppletLocatorData

Retrieves client data associated with an applet locator.

OSStatus JMGetAppletLocatorData (
                     JMAppletLocatorRef locatorRef,
                     JMClientData* data);
locatorRef
The applet locator whose client data you want to obtain.
data
A pointer to the client data. on return, this parameter points to the client data.
function result
A result code; see JManager Result Codes.

SEE ALSO

The JMSetAppletLocatorData function.

JMSetAppletLocatorData

Assigns client data to an applet locator.

OSStatus JMSetAppletLocatorData (
                     JMAppletLocatorRef locatorRef,
                     JMClientData data);
locatorRef
The applet locator whose client data you want to set.
data
The client data.
function result
A result code; see JManager Result Codes.

SEE ALSO

The JMGetAppletLocatorData function.

JMCountApplets

Counts the number of applets associated with an HTML page.

OSStatus JMCountApplets (
                     JMAppletLocatorRef locatorRef,
                     UInt32* appletCount);
locatorRef
The applet locator that contains the parsed HTML text.
appletCount
A pointer to the applet count. On return, this parameter points to the number of applets.
function result
A result code; see JManager Result Codes.

DISCUSSION

If there are no applets associated with the text, JMCountApplets returns 0. You can call this function only after successfully retrieving HTML text using The JMNewAppletLocator function.

SEE ALSO

Finding Applets.


JMGetAppletDimensions

Returns the dimensions of an applet.

OSStatus JMGetAppletDimensions (
                     JMAppletLocatorRef locatorRef,
                     UInt32 appletIndex,
                     UInt32* width,
                     UInt32* height);
locatorRef
The applet locator that contains the retrieved HTML text.
appletIndex
The index number of the applet you want to query.
width
A pointer that, on return, contains the width, in pixels, of the applet.
height
A pointer that, on return, contains the height, in pixels, of the applet.
function result
A result code; see JManager Result Codes.

DISCUSSION

The appletIndex value is an index number from 0 to appletCount -1, where appletCount is determined by the JMCountApplets function JMCountApplets. You can call this function only after successfully retrieving HTML text using The JMNewAppletLocator function.

SEE ALSO

Finding Applets.


JMGetAppletTag

Returns the tag associated with an applet.

OSStatus JMGetAppletTag (
                     JMAppletLocatorRef locatorRef,
                     UInt32 appletIndex,
                     JMTextRef* tagRef);
locatorRef
The applet locator that contains the retrieved HTML text.
appletIndex
The index number of the applet you want to query.
tagRef
A pointer to a text object. on return, the tagRef object contains the applet tag.
function result
A result code; see JManager Result Codes.

DISCUSSION

The JMGetAppletTag function returns the text bounded by the <APPLET> and </APPLET> delimeters in an HTML document. The appletIndex value is an index number from 0 to appletCount -1, where appletCount is determined by the JMCountApplets function JMCountApplets. You can call this function only after successfully retrieving HTML text using The JMNewAppletLocator function.

SEE ALSO

Finding Applets.


JMGetAppletName

Returns the name of an applet.

OSStatus JMGetAppletName (
                     JMAppletLocatorRef locatorRef,
                     UInt32 appletIndex,
                     JMTextRef* nameRef);
locatorRef
The applet locator that contains the retrieved HTML text.
appletIndex
The index number of the applet you want to query.
nameRef
A pointer to a text object. On return, the nameRef object contains the name of the applet.
function result
A result code; see JManager Result Codes.

DISCUSSION

The appletIndex value is an index number from 0 to appletCount -1, where appletCount is determined by the JMCountApplets function JMCountApplets. You must reserve a buffer for the text object containing the applet name and pass a pointer to the buffer when you call JMGetAppletName . You can call this function only after successfully retrieving HTML text using The JMNewAppletLocator function.

SEE ALSO

Finding Applets.


JMNewAppletViewer

Instantiates an applet.

OSStatus JMNewAppletViewer (
                     JMAppletViewerRef* viewer,
                     JMAWTContextRef context,
                     JMAppletLocatorRef locatorRef,
                     UInt32 appletIndex,
                     const JMAppletSecurity* security
                     const JMAppletViewerCallbacks* callbacks,
                     JMClientData data);
viewer
A pointer to an applet. On return, this parameter is the newly instantiated applet.

context
The AWT context associated with the applet.
locatorRef
The applet locator containing the applet.
appletIndex
The index of the applet to instantiate.
security
A pointer to the applet security structure. See Applet Security Structure for more information.
callbacks
A pointer to the applet viewer callbacks structure. See Applet Callbacks Structure for more information.
data
Optional client-specific data.
function result
A result code; see JManager Result Codes.

DISCUSSION

To instantiate an applet, you must first create an AWT context (and start the thread associated with it) and create an applet locator. The appletIndex value is an index number from 0 to appletCount -1, where appletCount is determined by the JMCountApplets function.

SEE ALSO

Instantiating Applets.

The JMCountApplets function.

The JMDisposeAppletViewer function.


JMDisposeAppletViewer

Removes an applet.

OSStatus JMDisposeAppletViewer (JMAppletViewerRef viewer);
viewer
The instantiated applet to remove.
function result
A result code; see JManager Result Codes.

DISCUSSION

Calling the JMDisposeAppletLocator function first halts execution of the applet if necessary. This function also disposes of the applet's frame (if visible) and any other frames created by the applet.

SEE ALSO

The JMNewAppletViewer function.


JMGetAppletViewerData

Retrieves client data associated with an applet.

OSStatus JMGetAppletViewerData (
                     JMAppletViewerRef viewer,
                     JMClientData* data);
viewer
The applet to query.
data
A pointer to the client data. On return, this parameter holds the client data.
function result
A result code; see JManager Result Codes.

SEE ALSO

The JMSetAppletViewerData function.

JMSetAppletViewerData

Assigns client data to an applet.

OSStatus JMSetAppletViewerData (
                     JMAppletViewerRef viewer,
                     JMClientData data);
viewer
The applet whose client data you want to set.
data
The client data.
function result
A result code; see JManager Result Codes.

SEE ALSO

The JMGetAppletViewerData function.

JMGetAppletViewerSecurity

Gets the security options for an applet.

extern OSStatus JMGetAppletViewerSecurity (
                     JMAppletViewerRef viewer,
                     JMAppletSecurity* data);
viewer
The applet whose security options you wish to determine.
data
A pointer to an applet security options structure. on return, this structure contains the security options for the specified applet. For more information, see Applet Security Structure.
function result
A result code; see JManager Result Codes.

SEE ALSO

The JMSetAppletViewerSecurity function.
The JMNewAppletViewer function.

JMSetAppletViewerSecurity

Sets the security options for an applet.

OSStatus JMSetAppletViewerSecurity (
                     JMAppletViewerRef viewer,
                     const JMAppletSecurity* data);
viewer
The applet whose security options you wish to change.
data
A pointer to an applet security options structure containing the new values to set. For more information, see Applet Security Structure.
function result
A result code; see JManager Result Codes.

SEE ALSO

The JMGetAppletViewerSecurity function.

JMReloadApplet

Loads (or reloads) an applet from its source server and executes it.

OSStatus JMReloadApplet (JMAppletViewerRef viewer);
viewer
The applet you want to execute.
function result
A result code; see JManager Result Codes.

DISCUSSION

You can also use this function to reload and restart the applet at any time (if the code has changed, for example). If you want to restart the applet without reloading the applet code, you should use The JMRestartApplet function.


JMRestartApplet

Restarts an applet without reloading it from the source server.

OSStatus JMRestartApplet (JMAppletViewerRef viewer);
viewer
The applet you want to execute.
function result
A result code; see JManager Result Codes.

DISCUSSION

This function corresponds to the Java method java.applet.Applet.start . If you want to reload the applet code before execution, you should use the JMReloadApplet function.


JMSuspendApplet

Suspends execution of an applet and any associated threads.

OSStatus JMSuspendApplet (JMAppletViewerRef viewer);
viewer
The applet you want to suspend.
function result
A result code; see JManager Result Codes.

DISCUSSION

This function corresponds to the Java method java.applet.Applet.stop .

SEE ALSO

The JMResumeApplet function.


JMResumeApplet

Resumes execution of a suspended applet.

OSStatus JMResumeApplet (JMAppletViewerRef viewer);
viewer
The applet you want to execute.
function result
A result code; see JManager Result Codes.

DISCUSSION

You can use the JMResumeApplet function to resume execution of an applet halted by the JMSuspendApplet function JMSuspendApplet. If you want to restart the applet from the beginning, you should use the JMRestartApplet function JMRestartApplet or the JMReloadApplet function JMReloadApplet.


JMGetFrameViewer

Finds the applet that owns a particular frame.

OSStatus JMGetFrameViewer (
                     JMFrameRef frame,
                     JMAppletViewerRef* viewer,
                     JMFrameRef* parentFrame);
frame
The frame whose applet you want to determine.
viewer
A pointer to the applet. On return, this parameter is the applet associated with the frame parameter.
parentFrame
A pointer to the parent frame. On return, this parameter is the applet's parent frame (that is, the one created for the applet when it was instantiated).
function result
A result code; see JManager Result Codes.

DISCUSSION

In the AWT context associated with the applet, the frame index of the parent frame is 0.

SEE ALSO

The JMCountAWTContextFramesfunction.


JMGetViewerFrame

Finds the parent frame for a given applet.

OSStatus JMGetViewerFrame (
                     JMAppletViewerRef viewer,
                     JMFrameRef* frame);
viewer
The applet whose parent frame you want to find.
frame
A pointer to the parent frame. On return, this parameter is the parent frame associated with the applet.
function result
A result code; see JManager Result Codes.

DISCUSSION

In the AWT context associated with the applet, the frame index of the parent frame is 0.

SEE ALSO

The JMCountAWTContextFramesfunction.


JMGetAppletViewerJNIObject

Returns a JNI reference to a JMAppletViewerRef object.

jobject JMGetAppletViewerJNIObject (
                     JMAppletViewerRef viewer,
                     JNIEnv * env);
viewer
The applet whose Java object you want to find.
env
A pointer to the current JNIEnv data structure.
function result
A pointer to the com.apple.mrj.JManager.JMAppletViewer Java object.

DESCRIPTION

The JMAppletViewerRef object is not the same as an applet object (that is, a java. applet.Applet object). A JMAppletViewer object encapsulates the Java applet object so it may be handled outside the Java environment.


JMGetAppletViewerObject

Returns a JRI reference to a JMAppletViewerRef object.

jref JMGetAppletViewerObject (JMAppletViewerRef viewer);
viewer
The applet whose Java object you want to find.
function result
A pointer to the com.apple.mrj.JManager.JMAppletViewer Java object.

DISCUSSION

The JMAppletViewerRef object is not the same as an applet object (that is, a java. applet.Applet object). A JMAppletViewer object encapsulates the Java applet object so it may be handled outside the Java environment.

Note that unless you specifically need to use the Java Runtime Interface (JRI), you should use the JMGetAppletViewerJNIObject function instead.


JMGetAppletJNIObject

Returns a JNI reference to the Java applet object.

jobject JMGetAppletJNIObject (
                     JMAppletViewerRef viewer,
                     JNIEnv * env);
viewer
The applet whose Java object you want to find.
env
A pointer to the current JNIEnv data structure.
function result
A pointer to the java.applet.Applet Java object.

DESCRIPTION

This function returns a reference to the actual applet object rather than to the JMAppletViewerRef object handled by the embedding application.


JMGetAppletObject

Returns a JRI reference to the Java applet object.

jref JMGetAppletObject (JMAppletViewerRef viewer);
viewer
The applet whose Java object you want to find.
function result
A pointer to the java.applet.Applet Java object.

DISCUSSION

This function returns a reference to the actual applet object rather than to the JMAppletViewerRef object handled by the embedding application.

Note that unless you specifically need to use the Java Runtime Interface (JRI), you should use the function instead.


© 1998 Apple Computer, Inc. — (Last Updated 3 Dec 98)